<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加核酸检查信息</title>

    <script src="/js/jquery-3.5.1.js"></script>

    <style>
        span {
            color: red;
        }
    </style>
</head>
<body>
<div style="width:330px;margin:auto">
    <form action="/addInfo" method="post">
        <table border="1px">
            <tr>
                <td colspan="2">
                    <h1>添加核酸检查信息</h1>
                </td>
            </tr>

            <tr>
                <td>
                    被检查人姓名<span>*</span>
                </td>

                <td>
                    <input type="text" name="assay_user" required/>
                </td>
            </tr>

            <tr>
                <td>
                    被检查人手机号<span>*</span>
                </td>

                <td>
                    <input type="text" name="phone" required/>
                </td>
            </tr>

            <tr>
                <td>
                    被检查人身份证号<span>*</span>
                </td>

                <td>
                    <input type="text" name="card_num" required/>
                </td>
            </tr>

            <tr>
                <td>
                    检测机构<span>*</span>
                </td>

                <td>
                    <select name="hospital_id" id="hospitalId">
                        <option value="0">--请选择--</option>
                        <option th:each="hospital:${hospitals}" th:value="${hospital.getId()}"
                                th:text="${hospital.getName()}"></option>
                    </select>
                </td>
            </tr>

            <tr>
                <td>
                    检测日期<span>*</span>
                </td>

                <td>
                    <input type="date" name="assay_time" required/>
                </td>
            </tr>

            <tr align="center">
                <td colspan="2">
                    <input type="submit" value="添加">
                    <input type="button" onclick="javascript:window.location.href='/page'" value="返回">
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
<script>

    $(function () {
        $("form").submit(function () {
            var hospital = $("#hospitalId").val();
            if (hospital == 0) {
                alert("请选择检测机构")
                return false;
            }
            return true;
        })
    })

</script>
</html>